<!DOCTYPE HTML>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联后台管理系统</title>
  <meta name="description" content="商之联后台管理系统">
  <meta name="keywords" content="form">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SUPPLIER_ADMIN_IMAGE')}favicon.png">
  <link rel="apple-touch-icon-precomposed" href="{:C('SUPPLIER_ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}admin.css">
  <link rel="stylesheet" type="text/css" href="{:C('SUPPLIER_ADMIN_CSS')}webuploader.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

<!-- header start-->

<include file="Public:header"/>

<!-- header end-->


<div class="am-cf admin-main">
<!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->

<!-- content start -->
<div class="admin-content">
 
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商品管理</strong> / <small>添加商品</small></div>
  </div>
 <form action="{:U('Item/saveItem')}" method="post" enctype="multipart/form-data" id="itemform">
  <div class="am-tabs am-margin" data-am-tabs="{noSwipe: 1}">
    <ul class="am-tabs-nav am-nav am-nav-tabs">
      <li class="am-active"><a href="#tab1">基本信息</a></li>
      <li><a href="#tab2">商品详情</a></li>
      <li><a href="#tab3">商品属性</a></li>
    </ul>

    <div class="am-tabs-bd">
    <!-- 商品基本信息-->
      <div class="am-tab-panel am-fade am-in am-active" id="tab1">
        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品类目</div>
          <div class="am-u-sm-10">
            <select name='itemtype' onchange="reload(this.options[this.options.selectedIndex].value)"  required="required">
            <option value=0>请选择</option>
            <foreach name="typearr" item="types" key="key">
            
              <option value="{$key}" <?php  if($typeid==$key) echo 'selected=1'; ?> > 
              <?php  echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',$types['level']);?> {$types['typename']}
              </option>
              </foreach>
            </select><span class="require-field">*</span>
          </div>
        </div>
  		
  		<div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right ">商品名称</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="itemname" id="option1" >
                <span class="require-field">*</span>
            </div>
          </div>
        </div>
		
		<div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品型号</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="bn">
            </div>
          </div>
        </div>
  		<if condition="$brands neq '' ">
         <div  class="am-g am-margin-top">
				<div class="am-u-sm-2 am-text-right">	
				品牌：
				</div>
					<div class="am-u-sm-10">
					
            <label for="brand"></label><input id="brand" name="brand" ><span class="require-field">*</span>
					</div>		
			</div>
	    </if>
		<!-- 属性end-->
        
    
			<div class='speccontain'>
			 <hr/>
		
				<div class='am-g am-margin-top'>
					<div class='am-u-sm-12'>
						<table class="am-table am-table-bordered am-table-striped am-table-compact" id='spectable'>
				    <thead>
				        <tr>	
				            <th>颜色</th>
                    <th>售价</th>
				            <th>供货价</th>
				            <th>库存</th>
                    <th>操作</th>
				        </tr>
				    </thead>
				    <tbody> 
				    </tbody>
				    </table>
				     <p>
				                  <button class="am-btn am-btn-default am-btn-xs am-text-secondary" 
				                   onclick=appendrow();return false;>
				            <span class="am-icon-pencil-square-o"></span>添加更多</button>
				                </p>
					</div>
					
				</div>
			<!--添加货品 -->
				<hr/>
		</div>
        <!--开启规格end-->
	

        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品价格</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="price" ><span class="require-field">*</span>
            </div>
          </div>
        </div>

        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">供货价</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="supperprice" ><span class="require-field">*</span>
            </div>
          </div>
        </div>

         <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">供货商</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
             <select name="supperid">
             <option value="0"> 选择供应商</option>
                <foreach name="suppliers" item="value" key="key">
                
                  <option value={$key}> {$value} </option>
                </foreach>
            
          </select>
            </div>
          </div>
        </div>



            <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">购买区</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
             <select name="areatype">
                <option value="0"> 请选择</option>
             <option value="1"> 现货区</option>
               <option value="3">店长推荐区</option>
              
               
            
          </select>
            </div>
          </div>
        </div>

         <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品库存</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="inventory" ><span class="require-field">*</span>
            </div>
          </div>
        </div>

      


         <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">列表图片</div>
          <div class="am-u-sm-10">
           <div class="am-form-group">
                  <input type="file"  name='listimg'>
                  <p class="am-form-help">请选择要上传的文件...(像素要求557*557)<span class="require-field">*</span></p>
                </div>
          </div>
        </div> 
        
      </div>
	<!-- 商品基本信息end-->
		<!-- 商品详情-->
      <div class="am-tab-panel am-fade" id="tab2">
       <script type="text/plain" id="container" style="width:1000px;height:540px;"></script>
      </div>
	<!-- 商品详情end -->

   <!--商品属性start -->
    <div class="am-tab-panel am-fade" id="tab3">
        <!--属性start-->
        <foreach name="typeproperty" item="propers" key="key" > 
          <div  class="am-g am-margin-top">
            <div class="am-u-sm-2 am-text-right">
              {$propers['propertyname']}
            </div>
              <div class="am-u-sm-10">
                <select name="proper[{$key}]">
                <option>请选择</option>
                <foreach name="propers.select" item="value" key="k">
                  
                  <option value="{$k}" >{$value['propertyvalue']}</option>
                </foreach>
                </select>
              </div>    
          </div>
          </foreach>

    </div>
   <!-- 商品属性end-->

    </div>
  </div>

  <div class="am-margin">
    <button type="submit" class="am-btn am-btn-primary am-btn-xs" >提交保存</button>
    <button type="reset" class="am-btn am-btn-primary am-btn-xs">重置</button>
  </div>
  </form>
</div>
<!-- content end -->

</div>

<!-- 回到顶部 start-->
  <div class="amz-toolbar" id="amz-toolbar" style="right:99.5px;position: fixed;z-index: 999;bottom: 10px;">
<a href="#top" title="回到顶部" class="am-icon-btn am-icon-arrow-up am-active" id="amz-go-top"></a>
 </div>
<!-- 回到顶部end -->

<!-- <footer>
  <hr>
  <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
</footer> -->
<script src="{:C('ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}jquery.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}third-party/jquery.min.js"></script>
<script type="text/javascript"charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}ueditor.all.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}jquery-1.8.3.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}jquery.validate.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}messages_zh.js"></script>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script type="text/javascript">
 function reload(x){
 	var typeid=x;
    window.location.href="{:U(Item/addItem)}"+"?typeid="+typeid;
 }
</script>
<script type="text/javascript">
function appendrow()
{
  event.preventDefault();
   var str='<tr class="row"><td><input type="text" name="p_color[]"/><td><input type="text" name="p_price[]"/></td><td><input type="text" name="supper_price[]"/></td><td><input type="text" name="p_inventory[]"/></td><td><button class="am-btn am-btn-default am-btn-xs am-text-danger" onclick=delproduct(this.parentNode)><span class="am-icon-trash-o"></span> 删除</button></td></tr>';
   $('#spectable').append(str);
} 
//删除product
function   delproduct(obj){
  event.preventDefault();
   var trnode=obj.parentNode;
   if(trnode) trnode.parentNode.removeChild(trnode);
}
</script>
<script type="text/javascript">
  /*自动补全*/
   $(function() {
    var availableTags = {$brands};
    $( "#brand" ).autocomplete({
      source: availableTags
    });
  });
   
</script>

 <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
    </script>
<script type="text/javascript">

$('#itemform').validate({
    rules:{
            itemname:{
              required:true,
              minlength:2
            },
            price:{
              required:true,
              number:true 
            },
            inventory:{
              required:true,
              number:true 
            },
            brand:{
              required:true
            }
    }
  });
//ajax 检测品牌是否唯一

  
$("input[name='brand']").change(function(){
  var brand=$("input[name='brand']").val();
 jQuery.get('{:U("Item/ajaxbrand")}',
  {brand:brand,},
  function(data){
  if(data.status===404){
    alert(data.info);
    $("input[name='brand']").val("");

  }
 },'json');

})



</script>
<script type="text/javascript">
  $(function(){
       var modultname="Item";

       $('.'+modultname).addClass('am-in');
});
</script>
</body>
</html>
